home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / objectex / ex37.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  596 b   |  27 lines

  1. Program ex37;
  2.  
  3. { Program to demonstrate the TStringCollection.Compare method }
  4.  
  5. Uses Objects;
  6.  
  7. Var C : PStringCollection;
  8.     S : String;
  9.     I : longint;
  10.     
  11. begin
  12.   Randomize;
  13.   C:=New(PStringCollection,Init(120,10));
  14.   C^.Duplicates:=True; { Duplicates allowed }
  15.   Writeln ('Inserting 100 records at random places.');
  16.   For I:=1 to 100 do
  17.     begin
  18.     Str(Random(100),S);
  19.     S:='String with value '+S;
  20.     C^.Insert(NewStr(S));
  21.     end;
  22.   For I:=0 to 98 do
  23.     With C^ do
  24.     If Compare (At(i),At(I+1))=0 then
  25.       Writeln ('Duplicate string found at position ',i);
  26.   Dispose(C,Done);
  27. end.